package com.eastfair.common.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableName;
import com.eastfair.core.base.entity.Entity;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import com.eastfair.annotation.model.EchoVO;
import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 
 * </p>
 *
 * @author clm
 * @since 2022-12-29
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("common_interface_call_record")
@ApiModel(value = "CommonInterfaceCallRecord", description = "")
@AllArgsConstructor
public class CommonInterfaceCallRecord extends Entity<Long> implements EchoVO {

    private static final long serialVersionUID = 1L;
    @TableField(exist = false)
    private Map<String, Object> echoMap = new HashMap<>();
    /**
     * 是否启用：1是；0否
     */
    @ApiModelProperty(value = "是否启用：1是；0否")
    @TableField(value = "is_enabled")
    @Excel(name = "是否启用：1是；0否")
    private Integer isEnabled;

    /**
     * 是否删除：1是；0否
     */
    @ApiModelProperty(value = "是否删除：1是；0否")
    @TableField(value = "is_deleted")
    @Excel(name = "是否删除：1是；0否")
    private Integer isDeleted;

    /**
     * 项目id
     */
    @ApiModelProperty(value = "项目id")
    @TableField(value = "project_id")
    @Excel(name = "项目id")
    private Long projectId;

    /**
     * 子系统id
     */
    @ApiModelProperty(value = "子系统id")
    @TableField(value = "subsystem_id")
    @Excel(name = "子系统id")
    private Long subsystemId;

    /**
     * 租户id
     */
    @ApiModelProperty(value = "租户id")
    @TableField(value = "tenant_id")
    @Excel(name = "租户id")
    private Long tenantId;

    /**
     * 团队id
     */
    @ApiModelProperty(value = "团队id")
    @TableField(value = "team_id")
    @Excel(name = "团队id")
    private Long teamId;

    /**
     * http请求地址
     */
    @ApiModelProperty(value = "http请求地址")
    @Size(max = 255, message = "http请求地址长度不能超过255")
    @TableField(value = "http_url", condition = LIKE)
    @Excel(name = "http请求地址")
    private String httpUrl;

    /**
     * 最后错误信息
     */
    @ApiModelProperty(value = "最后错误信息")
    @Size(max = 255, message = "最后错误信息长度不能超过255")
    @TableField(value = "error_msg", condition = LIKE)
    @Excel(name = "最后错误信息")
    private String errorMsg;

    /**
     * 最后错误code
     */
    @ApiModelProperty(value = "最后错误code")
    @TableField(value = "error_business_code")
    @Excel(name = "最后错误code")
    private Integer errorBusinessCode;

    /**
     * 重试次数
     */
    @ApiModelProperty(value = "重试次数")
    @TableField(value = "retry_count")
    @Excel(name = "重试次数")
    private Integer retryCount;

    /**
     * 状态-1 失败   1成功  0重试中
     */
    @ApiModelProperty(value = "状态-1 失败   1成功  0重试中")
    @TableField(value = "status")
    @Excel(name = "状态-1 失败   1成功  0重试中")
    private Integer status;

    /**
     * 最后httpcode
     */
    @ApiModelProperty(value = "最后httpcode")
    @TableField(value = "http_code")
    @Excel(name = "最后httpcode")
    private Integer httpCode;

    /**
     * 接口参数
     */
    @ApiModelProperty(value = "接口参数")
    @Size(max = 255, message = "接口参数长度不能超过255")
    @TableField(value = "http_attr", condition = LIKE)
    @Excel(name = "接口参数")
    private String httpAttr;

    /**
     * 请求方式
     */
    @ApiModelProperty(value = "请求方式")
    @Size(max = 255, message = "请求方式长度不能超过255")
    @TableField(value = "http_type", condition = LIKE)
    @Excel(name = "请求方式")
    private String httpType;

    /**
     * 最大重试次数（超过不再重试）
     */
    @ApiModelProperty(value = "最大重试次数（超过不再重试）")
    @TableField(value = "max_retry_count")
    @Excel(name = "最大重试次数（超过不再重试）")
    private Integer maxRetryCount;

    /**
     * 回调地址
     */
    @ApiModelProperty(value = "回调地址")
    @Size(max = 255, message = "回调地址长度不能超过255")
    @TableField(value = "callback_url", condition = LIKE)
    @Excel(name = "回调地址")
    private String callbackUrl;

    /**
     * 业务code
     */
    @ApiModelProperty(value = "业务code")
    @Size(max = 255, message = "业务code长度不能超过255")
    @TableField(value = "business_code", condition = LIKE)
    @Excel(name = "业务code")
    private String businessCode;

    /**
     * 业务线唯一id
     */
    @ApiModelProperty(value = "业务线唯一id")
    @Size(max = 255, message = "业务线唯一id长度不能超过255")
    @TableField(value = "trace_id", condition = LIKE)
    @Excel(name = "业务线唯一id")
    private String traceId;


    @Builder
    public CommonInterfaceCallRecord(Long id, Long createdBy, LocalDateTime createTime, Long updatedBy, LocalDateTime updateTime, 
                    Integer isEnabled, Integer isDeleted, Long projectId, Long subsystemId, Long tenantId, 
                    Long teamId, String httpUrl, String errorMsg, Integer errorBusinessCode, Integer retryCount, Integer status, 
                    Integer httpCode, String httpAttr, String httpType, Integer maxRetryCount, String callbackUrl, String businessCode, String traceId) {
        this.id = id;
        this.createdBy = createdBy;
        this.createTime = createTime;
        this.updatedBy = updatedBy;
        this.updateTime = updateTime;
        this.isEnabled = isEnabled;
        this.isDeleted = isDeleted;
        this.projectId = projectId;
        this.subsystemId = subsystemId;
        this.tenantId = tenantId;
        this.teamId = teamId;
        this.httpUrl = httpUrl;
        this.errorMsg = errorMsg;
        this.errorBusinessCode = errorBusinessCode;
        this.retryCount = retryCount;
        this.status = status;
        this.httpCode = httpCode;
        this.httpAttr = httpAttr;
        this.httpType = httpType;
        this.maxRetryCount = maxRetryCount;
        this.callbackUrl = callbackUrl;
        this.businessCode = businessCode;
        this.traceId = traceId;
    }

}
